package sctu.edu.java.year2016.team01.xuhanmei.day20160523.practice;

/**
 * Created by Administrator on 2016/5/23.
 */
public class soupsort {
    public static void main(String[] args) {
        int a[] = new int[]{23, 32, 45, 54, 67, 76};
        System.out.println("冒泡排序前的数组为：");
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + "  ");
        }
        System.out.println("\n冒泡排序的过程是：");
        for (int m = 0; m < a.length; m++) {
            for (int n = 0; n < a.length - m; n++) {
                if (a[n] > a[n + 1]) {
                    int temp = a[n];
                    a[n] = a[n + 1];
                    a[n + 1] = temp;
                }
                System.out.print(a[n] + "  ");
                for (int k = a.length - m; k < a.length; k++) {
                    System.out.print(a[k] + "  ");
                }
            }
        }
    }
}
